package net.simflow.swf.analyzer.data;

import java.io.File;
import java.util.ArrayList;

public class DirFileList {
	private static DirFileList instance = new DirFileList();

	private DirFileList() {
	}

	public static DirFileList getInstance() {
		return instance;
	}

	public File[] list(File dir, String[] exFilters) throws Exception {
		if (dir.isFile()) {
			return null;
		}

		File[] files = dir.listFiles();
		ArrayList<File> arrayFilesFilter = new ArrayList<File>();
		for (File file : files) {
			for (String filter : exFilters) {
				if (file.getName().endsWith(filter)) {
					arrayFilesFilter.add(file);
					break;
				}
			}
		}
		File[] filesResult = new File[arrayFilesFilter.size()];
		arrayFilesFilter.toArray(filesResult);
		return filesResult;
	}
}
